<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link rel="stylesheet" type="text/css" href="/plan/css/add.css"/>
    <script type="text/javascript" src="/plan/js/jquery.1.9.1.js" ></script>
    <script type="text/javascript" src="/plan/js/layer.js" ></script>
          	<script type="text/javascript" src="/plan/js/mobileSelect.js"></script>
	<link rel="stylesheet" type="text/css" href="/plan/css/mobileSelect.css"/>
    <script type="text/javascript" src="/plan/js/rem.js" ></script>
    <title>编辑计划</title>
</head>
{if $row->status == '-1'}
<style>
.list_info{
	padding: 0.3rem 0 0 0.5rem;
	background: #fff;
}
.list_info li{
	border-left: 1px solid #f0f0f0;
	padding: 0 0.3rem 0.45rem 0.4rem;
	position: relative;
}
.list_info li:last-child{
	border-left:none;
}
.tx{
	position: absolute;
	top: 0rem;
	left: -0.1rem;
	width: 0.2rem;
	height: 0.2rem;
	border-radius: 50%;
}
.infodate{
	width: 100%;
	overflow: hidden;
	padding-top: 0.2rem;
	font-size: 0.24rem;
	color: #999;
}
.title {
    font-size: 0.28rem;
    height: 0.6rem;
    line-height: 0.6rem;
    color: #666;
    margin-left: -0.18rem;
    padding-bottom: 0.4rem;
}
.question{
	float: left;
	width: 100%;
	margin-top: -0.1rem;
}
.question img{
	float: left;
	width: 0.5rem;
	height: 0.5rem;
	border-radius: 3px;
	margin-top: -0.05rem;
}
.question span{
	margin-left: 0.1rem;
}
.date{
	float: right;
	font-size: 0.24rem;
	color: #999;
}
.button {
    width: 100%;
    overflow: hidden;
    position: fixed;
    bottom: 0;
}
.button .again {
    width: 100%;
    background: #4876b2;
    color: #fff;
}
.pay {
    text-align: center;
    color: #fff;
    background: #4876b2;
    border: none;
    outline: none;
}
</style>
{/if}
<body>
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="" >
<ul class="order_money">
       <li>
		<span class="week">开会周次</span><span style="color: #f83535;">*</span>
		<div id="trigger4" class="trigger4" style="display: inline-block;width: 80%;margin-top: 0.1rem;  text-align: right;  float: right;">
		 	{$row->year}年 第{$row->week}周 {:date('m.d',strtotime($row->start_time)).'~'.date('m.d',strtotime($row->end_time))}
		</div>
		 <input type="hidden" name="row[year]" id="year" value="{$row->year}" />								
		 <input type="hidden" name="row[week]" id="week" value="{$row->start_time},{$row->end_time}" />								
	</li>
	    <li>
    		<span class="changci">开会场次</span>
    		<span style="color: #f83535;">*</span>
    		<select class="session" name="row[season]">
    			<option value="0">请选择</option>
    			<?php for($ad = 1;$ad<=14;$ad++ ){ ?>
    			<option value="{$ad}" {if $row->season == $ad}selected{/if}>{$ad}场</option>
    			<?php }?>
    		</select>
    </li>
    <li>
    		<span class="changdi">开会场地</span>
    		<span style="color: #f83535;float: left;margin-left: 0.1rem;">*</span>
    		<input class="address" type="text" name="row[address]" value="{$row->address}"  placeholder="请输入开会场地" />
    </li>
</ul>
<ul class="beizhu">
	<li>
		<p class="title">备注<span style="color: #f83535;">*</span></p>
        <textarea name="row[desc]"  placeholder="请输入备注信息" >{$row->desc}</textarea>
    </li>
</ul>
	<input id="status" name="row[status]" value="{$row->status}" type="hidden">
	<input id="id"  value="{$row->id}" type="hidden">
{if $row->status == '-1'}
  <ul class="list_info">
        		<p class="title">审批流程</p>
                     {volist name="$row.log" id="vo"}
        		<li>
                                {if $vo.type == 1}
        			<img class="tx" src="/plan/img/tongguo.jpg"/>
                                {else}
                                        <img class="tx" src="/plan/img/bohui.jpg"/>
                                {/if}
        			<p class="question">
        				<img src="{$vo.avatar_text}"/>
        				<span>{$vo.username}·{$vo.action}</span>
        				<span class="date">{:date('m/d  H:i',$vo['createtime'])}</span>
        			</p>
        			<p class="infodate">
        				“{$vo.content}”
        			</p>
        		</li>
                      {/volist}
        		
        </ul>
        <div class="button">
        		<div class="again"><input class="pay" type="button" onclick="tj(1)" value="重新提交"/></div>
        </div>
{else}
<div class="button">

		<a href="#"><div class="close" onclick="tj(0)">保存草稿</div></a>
		<div class="continue"><input class="pay" type="button" onclick="tj(1)"  value="提交审批" /></div>
</div>
{/if}


</form>
<script>
var arr = [];
	var DefaultsDate = 1;
	var DefaultsDateW = {$row->week}-1;
  	$.ajax({
	  url: '/api/ajax/years',
	  type: 'post',
	  async: false,
	  success: function (year) {
	  	console.log(year);
	  	   arr = year.data;
	  	 
	  		/*$.each(year.data,function (index,value) {
	  			 arr[index] = value;
	  			$.get('https://oa.fc62.com/api/ajax/year?year='+value.value,function (week) {
						arr[index]['childs'] = week.data;
					});

		   });*/
	  }
	});
	//周次联动
	var mobileSelect4 = new MobileSelect({
	    trigger: '#trigger4',
	    title: '周次选择',
	    wheels: [{data:arr}],
	    position:[DefaultsDate,DefaultsDateW],
		 transitionEnd:function(indexArr, data){
		        
		 },
		 callback:function(indexArr, data){
		    $('#week').val(data[1].id);
		    $('#year').val(data[0].id);
		    $('.week').css('font-size','0.2rem');
		 }
	});

</script>
<script>
 //同意 驳回
function tj(val) {
  $('#submit_to_save').val(val);
  var year = $('#year').val();
  var week = $('#week').val();
  var ids = $('#id').val();
	var season = $('.season').val();
	var address = $('.address').val();
	var txt = $('textarea').val();
	if(week == 0){
			layer.open({
			content:'请选择开会周次' ,
			skin: 'msg',
			time: 2 //2秒后自动关闭
		});
		return false
	}
	if(season == 0){
			layer.open({
			content:'请选择开会场次' ,
			skin: 'msg',
			time: 2 //2秒后自动关闭
		});
		return false
	}
	if(address == ''||address == null){
			layer.open({
			content:'请输入开会场次' ,
			skin: 'msg',
			time: 2 //2秒后自动关闭
		});
		return false
	}
	if(txt == ''||txt == null){
			layer.open({
			content:'请输入备注' ,
			skin: 'msg',
			time: 2 //2秒后自动关闭
		});
		return false
	}
	layer.open({type: 2});
	$.ajax({
	  type: 'post',
	  url:"/index/plan/edit/ids/"+ids,
	  data:{year:year,week:week,season:season,address:address,desc:txt,status:val},
	  dataType: "json",
	  success: function(data){
	  	console.log(data);
	  	if(data.code){
	  		 layer.open({
				content:'操作成功' ,
				skin: 'msg',
				time: 2 //2秒后自动关闭
			});
	  		 setTimeout(function () {
				window.location.href = "/index/plan/lists";
			},2000);
	  	}else{
	  		  //询问框
			  layer.open({
			    content: data.msg
			    ,btn: ['确定', '不要']
			    ,yes: function(index){
			      window.location.href = "/index/plan/view/ids/"+data.data;
			    }
			  });
	  	}
	  
	    //window.location.href = "";
	   }
	});
  //$('#add-form').submit();
}
$(function(){
	//字体变化
	$('#week').change(function(){
		var week = $('#week').val();
		if(week != 0){
			$('.zhou').css('font-size','0.2rem');
		}else{
			$('.zhou').css('font-size','0.28rem');
		}
	});
	$('.queding').click(function(){
		var week = $('#week').val();
		if(week != ''){
			$('.zhou').css('font-size','0.2rem');
		}else{
			$('.zhou').css('font-size','0.28rem');
		}
	});
	$('.session').change(function(){
		var session = $('.session').val();
		if(session != 0){
			$('.changci').css('font-size','0.2rem');
		}else{
			$('.changci').css('font-size','0.28rem');
		}
	});
	$('.address').keyup(function(){
		var address = $('.address').val();
		if(address != ''){
			$('.changdi').css('font-size','0.2rem');
		}else{
			$('.changdi').css('font-size','0.28rem');
		}
	});
	$('textarea').keyup(function(){
		var textarea = $('textarea').val();
		if(textarea != ''){
			$('.title').css('font-size','0.2rem');
		}else{
			$('.title').css('font-size','0.28rem');
		}
	});
});
	  
</script>

</body>
</html>
